package com.yunkazaixian.mqtt.utils;

import com.yunkazaixian.mqtt.entity.HttpResponse;

public class R {//code=0 操作成功

    public static HttpResponse ok(Object data) {
        return ok(0, "操作成功", data);
    }

    public static HttpResponse ok() {
        return ok(0, "操作成功", null);
    }


    public static HttpResponse ok(Object data, String msg) {
        return ok(0, msg, data);
    }

    public static HttpResponse ok(int code, String msg, Object data) {
        HttpResponse response = new HttpResponse();
        response.setCode(code);
        response.setMsg(msg);
        response.setData(data);
        return response;
    }


    public static HttpResponse fail(int code, String msg) {
        return fail(code, msg, null);
    }


    public static HttpResponse fail(String msg) {
        return fail(-1, msg, null);
    }

    public static HttpResponse fail() {
        return fail(-1, "操作失败", null);
    }

    public static HttpResponse fail(Object data, String msg) {
        return fail(-1, msg, data);
    }

    public static HttpResponse fail(int code, String msg, Object data) {
        HttpResponse response = new HttpResponse();
        response.setCode(code);
        response.setMsg(msg);
        response.setData(data);
        return response;
    }


}
